
 $(function(){  
    var search=decodeURI(window.location.search.substr(1)),
    meet=matchQueryString(search,'meet'),
    accountIdentifer=localCache.getSessionItem('account_identify'),
    url=localCache.getSessionItem('meet_detail_url'),
    header='<div class="title"><h2>time</h2><span>总时长</span><i>duration</i></div>',
    member='<dl><dt><h2>name</h2><span>status</span></dt><dd>time</dd></dl>',
    content=$('#detail'),
    noresult=$('#noresult'),
	jmeet=JSON.parse(meet);
    $('#back').on('click',function(){
      history.back();
    });

    function match(arr,value){
      for(var i=0;i<arr.length;i++){
        if(arr[i]==value||arr[i].indexOf(value)>-1){
          return i;
        }
      }
      return -1;
    }
    
    function searchProp(arr,name,value,key){
      for(var i=0;i<arr.length;i++){
        if(arr[i][name]==value){
          return arr[i][key];
        }
      }
      return '';
    }
    
    function create(json,from,htmls){
      var mems=json.mem.split(',');
      var times=json.times.split(',');
      var numbers=[json.caller].concat(json.phones.split(','));
	  for(var h=0;h<mems.length;h++){
        var n=searchProp(from,'telephone',mems[h],'name')||'参会人',index=match(numbers,mems[h]);
        htmls.push(member.replace('status','接听').replace('time',Math.ceil(times[h]/60)+'分钟').replace('name',n));	
		if(index!==-1){
			numbers.splice(index,1);
		}
      } 
	  for(var i=0;i<numbers.length;i++){
		var n=searchProp(from,'telephone',numbers[i],'name')||'参会人';
        htmls.push(member.replace('status','未接听').replace('time','0秒').replace('name',n));
	  }
      return htmls.join('');
    }
    
    $.ajax({
      type: "get",
      url: url,
      dataType: "jsonp",  
      data:{
        sessionId:jmeet.session_id,
        accountIdentifer:accountIdentifer, 
      },
      jsonp: "callback",
      success: function(json){
        if(json){
          var from=jmeet.data;
          var isAccepted=json.isAccepted;
          var htmls=[];
          if(isAccepted=='1'){
            htmls.push(header.replace('duration',json.cost+'分钟').replace('time',formatDate(jmeet.time)));    
            content.html(create(json,from,htmls)); 
          }else{
            noresult.css('display','block'); 			
          }
        }else{
            noresult.css('display','block'); 	
        }
      }
  });

    
 })
	
